# Group Tracks
Data related to the various tracks (e.g, python, AI, etc.) associated with the various sessions in the event.

| Parameter | Description | Type | Required |
|:----------|-------------|------|----------|
| `name`  | Name of the track | string | **yes** |
| `description` | Description of the track | string | - |
| `color` | Color code of the track **(can be in hex notation(e.g, #a04b4b) or decimal notation from 0 to 255(e.g, rgba(160, 75, 75, 0.5)))** | string | **yes** |
| `font-color` | Font Color of the track **(black/white: no user role - automatically updated)** | string | - |

## Tracks Collection [/v1/tracks{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
    + page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d (optional, integer, `2`) - Page number to be fetched for the paginated response.
    + sort (optional, string, `color`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
    + filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/filtering.html

### Create Track [POST]
Create a new track using an event_id.

+ Request (application/vnd.api+json)

    + Headers

            Authorization: JWT <Auth Key>

    + Body

            {
              "data": {
                "relationships":{
                  "event":{
                    "data":{
                      "type":"event",
                      "id":"1"
                    }
                  }
                },
                "attributes": {
                  "name" : "Main Track",
                  "description": "description",
                  "color": "#a04b4b"
                },
                "type": "track"
              }
            }

+ Response 201 (application/vnd.api+json)

        {
            "data": {
                "relationships": {
                  "event": {
                    "links": {
                      "self": "/v1/tracks/1/relationships/event",
                      "related": "/v1/tracks/1/event"
                    }
                  },
                  "sessions": {
                    "links": {
                      "self": "/v1/tracks/1/relationships/sessions",
                      "related": "/v1/tracks/1/sessions"
                    }
                  }
                },
                "attributes": {
                  "name" : "Main Track",
                  "description": "description",
                  "color": "#a04b4b",
                  "deleted-at": null,
                  "font-color":"#ffffff"
                },
                "type": "track",
                "id": "1",
                "links": {
                  "self": "/v1/tracks/1"
                }
            },
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/tracks/1"
            }
        }


## Track Detail [/v1/tracks/{track_id}]
+ Parameters
    + track_id: 1 (integer) - ID of the track in the form of an integer

### Get Details [GET]
Get a single track.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
            "data": {
                "relationships": {
                  "event": {
                    "links": {
                      "self": "/v1/tracks/1/relationships/event",
                      "related": "/v1/tracks/1/event"
                    }
                  },
                  "sessions": {
                    "links": {
                      "self": "/v1/tracks/1/relationships/sessions",
                      "related": "/v1/tracks/1/sessions"
                    }
                  }
                },
                "attributes": {
                  "name" : "Main Track",
                  "description": "description",
                  "color": "#a04b4b",
                  "deleted-at": null,
                  "font-color":"#ffffff"
                },
                "type": "track",
                "id": "1",
                "links": {
                  "self": "/v1/tracks/1"
                }
            },
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/tracks/1"
            }
        }


### Update Track [PATCH]
Update a single track by `id`.

+ `id` (integer) - ID of the record to update **(required)**

+ Request (application/vnd.api+json)

    + Headers

            Authorization: JWT <Auth Key>

    + Body


            {
              "data": {
                "attributes": {
                  "name" : "Main Track",
                  "description": "description",
                  "color": "#a04b4b"
                },
                "type": "track",
                "id": "1"
              }
            }

+ Response 200 (application/vnd.api+json)

        {
            "data": {
                "relationships": {
                    "event": {
                        "links": {
                            "self": "/v1/tracks/1/relationships/event",
                            "related": "/v1/tracks/1/event"
                        }
                    },
                    "sessions": {
                        "links": {
                            "self": "/v1/tracks/1/relationships/sessions",
                            "related": "/v1/tracks/1/sessions"
                        }
                    }
                },
                "attributes": {
                    "color": "#a04b4b",
                    "description": "description",
                    "name": "Main Track",
                    "deleted-at": null,
                    "font-color": "#ffffff"
                },
                "type": "track",
                "id": "1",
                "links": {
                    "self": "/v1/tracks/1"
                }
            },
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/tracks/1"
            }
        }

### Delete Track [DELETE]
Delete a single track.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
          "meta": {
            "message": "Object successfully deleted"
          },
          "jsonapi": {
            "version": "1.0"
          }
        }


## Tracks under an Event [/v1/events/{event_identifier}/tracks{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
    + event_identifier: 1 (string) - identifier or event id of the event. (b8324ae2 is an example of identifier)
    + page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d (optional, integer, `2`) - Page number to fetched for the paginated response.
    + sort (optional, string, `name`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
    + filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/filtering.html for more.

### Get List of Tracks under an Event [GET]
Get a single track.


+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
            "meta": {
                "count": 1
            },
            "data": [
                {
                    "relationships": {
                        "event": {
                            "links": {
                                "self": "/v1/tracks/1/relationships/event",
                                "related": "/v1/tracks/1/event"
                            }
                        },
                        "sessions": {
                            "links": {
                                "self": "/v1/tracks/1/relationships/sessions",
                                "related": "/v1/tracks/1/sessions"
                            }
                        }
                    },
                    "attributes": {
                        "color": "#a04b4b",
                        "description": "description",
                        "name": "Main Track",
                        "deleted-at": null,
                        "font-color": "#ffffff"
                    },
                    "type": "track",
                    "id": "1",
                    "links": {
                        "self": "/v1/tracks/1"
                    }
                }
            ],
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/events/1/tracks"
            }
        }


## Tracks Details of a Session [/v1/sessions/{session_id}/track]
+ Parameters
    + session_id: 1 (integer) - ID of the session in the form of an integer

### Get Track Details of a Session [GET]
Get a single track.


+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
            "data": {
                "relationships": {
                    "event": {
                        "links": {
                            "self": "/v1/tracks/1/relationships/event",
                            "related": "/v1/tracks/1/event"
                        }
                    },
                    "sessions": {
                        "links": {
                            "self": "/v1/tracks/1/relationships/sessions",
                            "related": "/v1/tracks/1/sessions"
                        }
                    }
                },
                "attributes": {
                    "color": "#a04b4b",
                    "description": "description",
                    "name": "Main Track",
                    "deleted-at": null,
                    "font-color": "#ffffff"
                },
                "type": "track",
                "id": "1",
                "links": {
                    "self": "/v1/tracks/1"
                }
            },
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/tracks/1"
            }
        }
